#!/bin/sh

#Setup script
#$1: BUILDDIR; $2: Libraries to check for
BUILD_DIR="$1"
LIBS=($2)

. ./common.sh

echo "Checking for build prerequisites..."

stateSet "Build directory:"

if [ ! -d "$BUILD_DIR" ]; then
    mkdir "$BUILD_DIR"
    if [ $? -eq 0 ] ; then
	stateGreen "CREATED"
    else
	stateRed "UNABLE TO CREATE"
	exit 1
    fi
else
    stateGreen "FOUND"
fi

echo "Checking for the required libraries..."

for lib in ${LIBS[*]} ; do
    stateSet "$lib..."
    checkLib $lib

    if [ $? -eq 0 ] ; then
	stateGreen "FOUND"
    else
	stateRed "NOT FOUND"
	exit 1
    fi

done
